﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:v="clr-namespace:ShredTheLog.Views;assembly=ShredTheLog.Views"
    xmlns:vm="clr-namespace:ShredTheLog.ViewModels;assembly=ShredTheLog.ViewModels"
    xmlns:cnv="clr-namespace:ShredTheLog.Converters;assembly=ShredTheLog.Converters"
    xmlns:sysWin="clr-namespace:System.Windows;assembly=WindowsBase"
    xmlns:c="clr-namespace:ShredTheLog.Controls;assembly=ShredTheLog.Controls"
    xmlns:se="clr-namespace:ShredTheLog.ShaderEffectLibrary;assembly=ShredTheLog.ShaderEffectLibrary"
    >

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="OdigoMisc2.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <DataTemplate DataType="{x:Type vm:MainViewModel}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="100"/>
            </Grid.RowDefinitions>

            <Border Grid.Row="0" CornerRadius="10" BorderBrush="{StaticResource MainPanelBorderBrush}" BorderThickness="1" Background="{StaticResource MainPanelBackgroundBrush}">
                <DockPanel>
                    <Menu DockPanel.Dock="Top" Margin="8, 1, 8, 1">
                        <MenuItem Header="{c:LocalizedString s_Login}" c:Extensions.Items="{Binding Path=FileMenuCommands, Converter={x:Static vm:MenuItemsConverter.Default}}"/>
                        <MenuItem Header="{c:LocalizedString s_View}" c:Extensions.Items="{Binding Path=ViewMenuCommands, Converter={x:Static vm:MenuItemsConverter.Default}}"/>
                        <MenuItem Header="{c:LocalizedString s_Odigo_Tools}" c:Extensions.Items="{Binding Path=ToolsMenuCommands, Converter={x:Static vm:MenuItemsConverter.Default}}"/>
                        <MenuItem Header="{c:LocalizedString s_Odigo_Help}" c:Extensions.Items="{Binding Path=HelpMenuCommands, Converter={x:Static vm:MenuItemsConverter.Default}}"/>
                    </Menu>

                    <TabControl ItemsSource="{Binding Pages}" IsSynchronizedWithCurrentItem="True" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                        <TabControl.Template>
                            <ControlTemplate TargetType="{x:Type TabControl}">
                                <Border x:Name="roundedBorder" Margin="3, 0, 3, 3" CornerRadius="5" BorderBrush="{StaticResource MainPanelBorderBrush}" BorderThickness="1">
                                    <DockPanel>
                                        <UIElement.Clip>
                                            <MultiBinding Converter="{x:Static cnv:RectangleGeometryConverter.Default}">
                                                <Binding ElementName="roundedBorder" Path="ActualWidth"/>
                                                <Binding ElementName="roundedBorder" Path="ActualHeight"/>
                                                <Binding ElementName="roundedBorder" Path="CornerRadius.BottomLeft"/>
                                                <Binding ElementName="roundedBorder" Path="BorderThickness.Left"/>
                                            </MultiBinding>    
                                        </UIElement.Clip>
                                        
                                        <Border DockPanel.Dock="Top" Background="Transparent" KeyboardNavigation.TabNavigation="Local">
                                            <TabPanel x:Name="HeaderPanel" Margin="0" IsItemsHost="true" Panel.ZIndex="1" Grid.Column="1" KeyboardNavigation.TabIndex="1"/>
                                        </Border>

                                        <Grid Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="1" Background="{StaticResource MainTabItemBackgroundBrush}">
                                            <Border CornerRadius="0, 0, 3, 3" BorderBrush="#2D4064" BorderThickness="3, 0, 3, 3">
                                                <Border.Effect>
                                                    <BlurEffect KernelType="Gaussian" RenderingBias="Performance" Radius="8"/>
                                                </Border.Effect>
                                            </Border>
                                            <ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local"/>
                                        </Grid>
                                    </DockPanel>
                                </Border>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsEnabled" Value="false">
                                        <Setter Property="Foreground" Value="Gray"/>
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </TabControl.Template>
                        
                        <TabControl.ItemContainerStyle>
                            <Style TargetType="{x:Type TabItem}">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type TabItem}">
                                            <ControlTemplate.Resources>
                                                <ResourceDictionary Source="OdigoMainTabControlItems.xaml"/>
                                            </ControlTemplate.Resources>
                                            
                                            <Grid MinWidth="{TemplateBinding MinWidth}">
                                                <Border x:Name="border" Padding="{TemplateBinding Padding}" BorderBrush="Black" BorderThickness="0, 0, 1, 0">
                                                    <Border.Background>
                                                        <LinearGradientBrush StartPoint="0.5, 0" EndPoint="0.5, 1">
                                                            <GradientStop Offset="0" Color="#495F89"/>
                                                            <GradientStop Offset="0.2" Color="{StaticResource MainTabItemBackgroundColor}"/>
                                                            <GradientStop Offset="1" Color="{StaticResource MainTabItemBackgroundColor}"/>
                                                        </LinearGradientBrush>
                                                    </Border.Background>
                                                    <ContentPresenter HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" RecognizesAccessKey="True" ContentSource="Header"/>
                                                </Border>
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsSelected" Value="false">
                                                    <Setter TargetName="border" Property="Effect">
                                                        <Setter.Value>
                                                            <se:MonochromeEffect FilterColor="#B3A8BB"/>
                                                        </Setter.Value>
                                                    </Setter>
                                                    <Setter TargetName="border" Property="BorderThickness" Value="0, 0, 1, 1"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </TabControl.ItemContainerStyle>
                    </TabControl>
                </DockPanel>
            </Border>
        </Grid>
    </DataTemplate>
</ResourceDictionary>